import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
//import 'package:flutter_swiper/flutter_swiper.dart';

class HomeIindexPage extends StatefulWidget {
  HomeIindexPage({Key key}) : super(key: key);

  @override
  _HomeIindexPageState createState() => _HomeIindexPageState();
}

class _HomeIindexPageState extends State<HomeIindexPage> {
  List<String> listImg = [
    'assets/images/swiper_1.jpeg',
    'assets/images/swiper_2.jpeg',
    'assets/images/swiper_3.jpeg',
  ];

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Color.fromRGBO(196, 148, 81, 0.5),
      appBar: AppBar(
        title: Text('首页'),
      ),
      body: ListView(
        children: <Widget>[
          //轮播图
          new Container(
            height: 250,
            child: Swiper(
              scrollDirection: Axis.horizontal, // 横向
              itemCount: 3, // 数量
              autoplay: true, // 自动翻页
              itemBuilder: (BuildContext context, int index) {
                return Image.asset(listImg[index], fit: BoxFit.fill);
              }, // 构建
              onTap: (index) {
                print(context);
              }, // 点击事件 onTap
              // 选中时的颜色
            ),
          ),
          //标题
          new Padding(
            padding: EdgeInsets.all(10),
            child: Container(
              //  margin: EdgeInsets.only(left: 40, top: 40),
//设置 child 居中
              alignment: Alignment(0, 0),
              height: 50,
              width: 300,
//边框设置
              decoration: new BoxDecoration(
//背景
                color: Colors.white,
                //设置四周圆角 角度
                borderRadius: BorderRadius.all(Radius.circular(5.0)),
                //设置四周边框
                border: new Border.all(
                    width: 2, color: Color.fromRGBO(196, 148, 81, 1)),
              ),
              child: Text(
                "文章推荐",
                style: TextStyle(fontSize: 20),
              ),
            ),
          ),
          //推荐内容
          new Padding(
            padding: EdgeInsets.only(top: 5, left: 10, right: 10, bottom: 10),
            child: Container(
              // color: Colors.white,
              child: Column(
                children: <Widget>[
                  new Container(
                    alignment: Alignment(0, 0),
                    height: 260,
                    width: double.infinity,
                    decoration: new BoxDecoration(
                      color: Colors.white,
                      //设置四周圆角 角度
                      borderRadius: BorderRadius.all(Radius.circular(5.0)),
                      //设置四周边框
                      border: new Border.all(
                          width: 2, color: Color.fromRGBO(196, 148, 81, 1)),
                    ),
                    child: InkWell(
                      onTap: () {
                        print('点击跳转页面');
                      },
                      child: Column(
                        children: <Widget>[
                          Container(
                            color: Colors.white,
                            width: double.infinity,
                            height: 210,
                            child: Image.asset(
                              'assets/images/swiper_1.jpeg',
                              fit: BoxFit.cover,
                            ),
                          ),
                          Row(
                            // crossAxisAlignment: CrossAxisAlignment.start,
                            children: <Widget>[
                              Padding(
                                padding: EdgeInsets.only(
                                    top: 10, left: 10, bottom: 10, right: 10),
                                child: Text(
                                  'data',
                                  style: TextStyle(
                                      fontSize: 20,
                                      color: Colors.blueGrey[300]),
                                ),
                              ),
                              new Expanded(
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.end,
                                  children: <Widget>[
                                    Padding(
                                      padding: EdgeInsets.all(0),
                                      child: Icon(
                                        Icons.chevron_right,
                                        color: Colors.blueGrey[300],
                                      ),
                                    )
                                  ],
                                ),
                              )
                            ],
                          ),
                        ],
                      ),
                    ),
                  )
                ],
              ),
            ),
          ),
          new Padding(
            padding: EdgeInsets.only(top: 5, left: 10, right: 10, bottom: 10),
            child: Container(
              // color: Colors.white,
              child: Column(
                children: <Widget>[
                  new Container(
                    alignment: Alignment(0, 0),
                    height: 260,
                    width: double.infinity,
                    decoration: new BoxDecoration(
                      color: Colors.white,
                      //设置四周圆角 角度
                      borderRadius: BorderRadius.all(Radius.circular(5.0)),
                      //设置四周边框
                      border: new Border.all(
                          width: 2, color: Color.fromRGBO(196, 148, 81, 1)),
                    ),
                    child: InkWell(
                      onTap: () {
                        print('点击跳转页面');
                      },
                      child: Column(
                        children: <Widget>[
                          Container(
                            color: Colors.white,
                            width: double.infinity,
                            height: 210,
                            child: Image.asset(
                              'assets/images/swiper_1.jpeg',
                              fit: BoxFit.cover,
                            ),
                          ),
                          Row(
                            // crossAxisAlignment: CrossAxisAlignment.start,
                            children: <Widget>[
                              Padding(
                                padding: EdgeInsets.only(
                                    top: 10, left: 10, bottom: 10, right: 10),
                                child: Text(
                                  'data',
                                  style: TextStyle(
                                      fontSize: 20,
                                      color: Colors.blueGrey[300]),
                                ),
                              ),
                              new Expanded(
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.end,
                                  children: <Widget>[
                                    Padding(
                                      padding: EdgeInsets.all(0),
                                      child: Icon(
                                        Icons.chevron_right,
                                        color: Colors.blueGrey[300],
                                      ),
                                    )
                                  ],
                                ),
                              )
                            ],
                          ),
                        ],
                      ),
                    ),
                  )
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }
}
